<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	layout:decorator="layout/default">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>修改密码</title>
</head>
<body>
	<div layout:fragment="content">
		<script type='text/javascript'>
			function submitform() {
				if (jQuery.trim($("#password").val()) != jQuery.trim($(
						"#confirm_psd").val())) {
					alert("两次输入的密码不一致，请重新输入");
					$("#confirm_psd").val("");
					$("#confirm_psd").focus();
					return false;
				}
				if (jQuery.trim($("#password").val()) == jQuery.trim($(
						"#old_password").val())) {
					alert("您输入的新密码与旧密码相同，请设置不同的密码");
					$("#password").val("");
					$("#confirm_psd").val("");
					$("#password").focus();
					return false;
				}
				return true;
			}
		</script>
		<form class="form-horizontal" action="" method="POST"
			th:object="${authUser}" onsubmit="return submitform();">
			<fieldset>
				<legend>修改密码</legend>
				<input type="hidden" id="action" name="action" value="change" /> <input
					type="hidden" th:field="*{userId}" />
				<div class="form-group">
					<label for="userName"
						class="col-lg-2 col-md-2 col-sm-2 hidden-xs control-label">登录名称</label>
					<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
						<input type="text" class="form-control input-sm"
							th:field="*{userName}" readonly="readonly" />
					</div>
				</div>
				<div class="form-group">
					<label for="old_password"
						class="col-lg-2 col-md-2 col-sm-2 hidden-xs control-label">旧密码</label>
					<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
						<input type="password" class="form-control input-sm"
							id="old_password" name="old_password" maxLength="64" required="required"
							requireText="请输入旧密码" placeHolder="旧密码" autofocus="autofocus" />
							<small class="text-warning" th:if="${msg}" th:utext="${msg}"></small>
					</div>
				</div>
				<div class="form-group"
					th:classappend="${#fields.hasErrors('password')} ? 'has-error'">
					<label for="password"
						class="col-lg-2 col-md-2 col-sm-2 hidden-xs control-label">新密码</label>
					<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
						<input type="password" class="form-control input-sm"
							th:field="*{password}" maxLength="64" required="required"
							requireText="请输入新密码" placeHolder="新密码" autofocus="autofocus" />
						<small class="text-warning"
							th:if="${#fields.hasErrors('password')}" th:errors="*{password}"></small>
					</div>
				</div>
				<div class="form-group">
					<label for="password"
						class="col-lg-2 col-md-2 col-sm-2 hidden-xs control-label">确认密码</label>
					<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">
						<input type="password" class="form-control input-sm"
							id="confirm_psd" maxLength="64" required="required"
							requireText="请再输入一次新密码" placeHolder="请再输入一次新密码" />
					</div>
				</div>
				<div class="row">
					<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
						<input type="submit"
							class="col-lg-offset-3 col-md-offset-3 col-lg-5 col-md-4 col-sm-4 btn btn-lg btn-success"
							value="保存数据" /> <input type="reset"
							class="col-lg-offset-1 col-md-offset-1 col-sm-offset-1 btn btn-lg btn-default"
							value="重置" /> <a class="btn btn-lg btn-default" role="button"
							th:href="@{/users}">返回列表</a>
					</div>
				</div>
			</fieldset>
		</form>
	</div>
</body>
</html>
